package com.example.myapplication;

import androidx.appcompat.app.AppCompatActivity;

import android.app.AlertDialog;
import android.app.Dialog;
import android.content.Context;
import android.content.DialogInterface;
import android.os.Bundle;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;

public class ExpendPage extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_expend_page);


    }
    public void writeDownDialog(View view){
        View views = getLayoutInflater().inflate(R.layout.dialog, null);
        MyDialog mMyDialog = new MyDialog(this, 0, 0, views, R.style.DialogTheme);
        mMyDialog.setCancelable(true);
        mMyDialog.show();
    }
    public class MyDialog extends Dialog {
        //    style引用style样式
        public MyDialog(Context context, int width, int height, View layout, int style) {

            super(context, style);

            setContentView(layout);

            Window window = getWindow();

            WindowManager.LayoutParams params = window.getAttributes();

            params.gravity = Gravity.CENTER;

            window.setAttributes(params);
        }
    }

}
